/**
* @file dvpp.cpp
*
* Copyright (C) Huawei Technologies Co., Ltd. 2019-2020. All Rights Reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#include "acl/ops/acl_dvpp.h"
#include "common/log_inner.h"
#include "error_codes_inner.h"
#include "single_op/dvpp/common/dvpp_util.h"
#include "single_op/dvpp/mgr/dvpp_manager.h"
#include "single_op/dvpp/common/dvpp_def_internal.h"
#include "toolchain/profiling_manager.h"
#include "toolchain/resource_statistics.h"

namespace {
    constexpr size_t MEMORY_ALIGN_SIZE = 32UL;
    constexpr uint32_t BATCH_MAX_SIZE = 256U;
    constexpr uint32_t DVPP_BORDER_CONFIG_INVALID_VALUE = 0U;

    static aclError GetAlignedSizeForDvpp(const size_t size, size_t &alignedSize)
    {
        // check overflow, the max value of size must be less than 0xFFFFFFFFFFFFFFFF-32*2
        if ((size + (MEMORY_ALIGN_SIZE * 2UL)) < size) {
            ACL_LOG_INNER_ERROR("[Check][Size]size too large: %zu", size);
            return ACL_ERROR_INVALID_PARAM;
        }

        // // align size to multiple of 32 and puls 32
        alignedSize = (size + (MEMORY_ALIGN_SIZE * 2UL) - 1UL) /
            MEMORY_ALIGN_SIZE * MEMORY_ALIGN_SIZE;
        return ACL_SUCCESS;
    }

    aclError CopyChannelDescParam(const void *const src, const size_t srcLen, void *const dst, const size_t dstLen)
    {
        ACL_REQUIRES_NOT_NULL(src);
        ACL_REQUIRES_NOT_NULL(dst);
        if (srcLen > dstLen) {
            ACL_LOG_INNER_ERROR("[Check][Len]src length=%zu is larger than dst length=%zu when memcpy", srcLen, dstLen);
            return ACL_ERROR_INVALID_PARAM;
        }
        const auto ret = memcpy_s(dst, dstLen, src, srcLen);
        if (ret != EOK) {
            ACL_LOG_INNER_ERROR("[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%zu",
                ret, srcLen, dstLen);
            return ACL_ERROR_FAILURE;
        }

        return ACL_SUCCESS;
    }

    aclError SetVencChannelDescThreadId(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint64_t threadId = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&threadId),
                                                                sizeof(uint64_t)), "memcpy value failed");
        return aclvencSetChannelDescThreadId(channelDesc, threadId);
    }

    aclError SetVencChannelDescCallback(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        aclvencCallback callback = nullptr;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&callback),
                                                                sizeof(size_t)), "memcpy value failed");
        return aclvencSetChannelDescCallback(channelDesc, callback);
    }

    aclError SetVencChannelDescPicFormat(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppPixelFormat picFormat = PIXEL_FORMAT_YUV_400;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picFormat),
                                                                sizeof(acldvppPixelFormat)), "memcpy value failed");
        return aclvencSetChannelDescPicFormat(channelDesc, picFormat);
    }

    aclError SetVencChannelDescEnType(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppStreamFormat enType = H265_MAIN_LEVEL;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&enType),
                                                                sizeof(acldvppStreamFormat)), "memcpy value failed");
        return aclvencSetChannelDescEnType(channelDesc, enType);
    }

    aclError SetVencChannelDescPicWidth(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t picWidth = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picWidth),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescPicWidth(channelDesc, picWidth);
    }

    aclError SetVencChannelDescPicHeight(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t picHeight = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picHeight),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescPicHeight(channelDesc, picHeight);
    }

    aclError SetVencChannelDescKeyFrameInterval(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t keyFrameInterval = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&keyFrameInterval),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescKeyFrameInterval(channelDesc, keyFrameInterval);
    }

    aclError SetVencChannelDescBufAddr(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        void *bufAddr = nullptr;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&bufAddr),
                                                                sizeof(size_t)), "memcpy value failed");
        return aclvencSetChannelDescBufAddr(channelDesc, bufAddr);
    }

    aclError SetVencChannelDescBufSize(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t bufSize = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&bufSize),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescBufSize(channelDesc, bufSize);
    }

    aclError SetVencChannelDescRcMode(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t rcMode = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&rcMode),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescRcMode(channelDesc, rcMode);
    }

    aclError SetVencChannelDescSrcRate(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t srcRate = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&srcRate),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescSrcRate(channelDesc, srcRate);
    }

    aclError SetVencChannelDescMaxBitRate(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t maxBitRate = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&maxBitRate),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvencSetChannelDescMaxBitRate(channelDesc, maxBitRate);
    }

    aclError SetVencChannelDescIpProp(aclvencChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t ipProp = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&ipProp),
                                                                sizeof(uint32_t)), "memcpy value failed");
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        return videoProcessor->aclvencSetChannelDescIPProp(channelDesc, ipProp);
    }

    aclError GetVencChannelDescThreadId(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint64_t threadId = aclvencGetChannelDescThreadId(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&threadId),
            sizeof(uint64_t), param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint64_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescCallback(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const aclvencCallback callback = aclvencGetChannelDescCallback(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&callback), sizeof(size_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(size_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescPicFormat(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const acldvppPixelFormat picFormat = aclvencGetChannelDescPicFormat(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picFormat),
            sizeof(acldvppPixelFormat), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppPixelFormat);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescEnType(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const acldvppStreamFormat enType = aclvencGetChannelDescEnType(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&enType),
            sizeof(acldvppStreamFormat), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppStreamFormat);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescPicWidth(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t picWidth = aclvencGetChannelDescPicWidth(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picWidth), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescPicHeight(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t picHeight = aclvencGetChannelDescPicHeight(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picHeight), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescKeyFrameInterval(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t keyFrameInterval = aclvencGetChannelDescKeyFrameInterval(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&keyFrameInterval),
            sizeof(uint32_t), param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescBufAddr(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        bool isSupport = false;
        void *const bufAddr = videoProcessor->aclvencGetChannelDescBufAddr(channelDesc, isSupport);
        if (!isSupport) {
            return ACL_ERROR_FEATURE_UNSUPPORTED;
        }

        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&bufAddr), sizeof(size_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(size_t);
        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescBufSize(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        bool isSupport = false;
        const uint32_t bufSize = videoProcessor->aclvencGetChannelDescBufSize(channelDesc, isSupport);
        if (!isSupport) {
            return ACL_ERROR_FEATURE_UNSUPPORTED;
        }

        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&bufSize), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescRcMode(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        bool isSupport = false;
        const uint32_t rcMode = videoProcessor->aclvencGetChannelDescRcMode(channelDesc, isSupport);
        if (!isSupport) {
            return ACL_ERROR_FEATURE_UNSUPPORTED;
        }

        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&rcMode), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescSrcRate(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        bool isSupport = false;
        const uint32_t srcRate = videoProcessor->aclvencGetChannelDescSrcRate(channelDesc, isSupport);
        if (!isSupport) {
            return ACL_ERROR_FEATURE_UNSUPPORTED;
        }

        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&srcRate), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescMaxBitRate(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        bool isSupport = false;
        const uint32_t maxBitRate = videoProcessor->aclvencGetChannelDescMaxBitRate(channelDesc, isSupport);
        if (!isSupport) {
            return ACL_ERROR_FEATURE_UNSUPPORTED;
        }
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&maxBitRate),
            sizeof(uint32_t), param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError GetVencChannelDescIpProp(const aclvencChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");

        const uint32_t ipProp = videoProcessor->aclvencGetChannelDescIPProp(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&ipProp), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);

        return ACL_SUCCESS;
    }

    aclError SetVdecChannelDescMatrix(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length,
            static_cast<void *>(&matrixFormat), sizeof(acldvppCscMatrix)), "memcpy value failed");

        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        return videoProcessor->aclvdecSetChannelDescMatrix(channelDesc, matrixFormat);
    }

    aclError SetVdecChannelDescOutMode(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t outMode = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&outMode),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescOutMode(channelDesc, outMode);
    }

    aclError SetVdecChannelDescThreadId(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint64_t threadId = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&threadId),
                                                                sizeof(uint64_t)), "memcpy value failed");
        return aclvdecSetChannelDescThreadId(channelDesc, threadId);
    }

    aclError SetVdecChannelDescCallback(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        aclvdecCallback callback = nullptr;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&callback),
                                                                sizeof(size_t)), "memcpy value failed");
        return aclvdecSetChannelDescCallback(channelDesc, callback);
    }

    aclError SetVdecChannelDescChannelId(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t channelId = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&channelId),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescChannelId(channelDesc, channelId);
    }

    aclError SetVdecChannelDescEnType(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppStreamFormat enType = H265_MAIN_LEVEL;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&enType),
                                                                sizeof(acldvppStreamFormat)), "memcpy value failed");
        return aclvdecSetChannelDescEnType(channelDesc, enType);
    }

    aclError SetVdecChannelDescOutPicFormat(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppPixelFormat picFormat = PIXEL_FORMAT_YUV_400;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picFormat),
            sizeof(acldvppPixelFormat)), "memcpy value failed");
        return aclvdecSetChannelDescOutPicFormat(channelDesc, picFormat);
    }

    aclError SetVdecChannelDescOutPicWidth(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t picWidth = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picWidth),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescOutPicWidth(channelDesc, picWidth);
    }

    aclError SetVdecChannelDescOutPicHeight(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t picHeight = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&picHeight),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescOutPicHeight(channelDesc, picHeight);
    }

    aclError SetVdecChannelDescRefFrameNum(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t refFrameNum = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&refFrameNum),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescRefFrameNum(channelDesc, refFrameNum);
    }

    aclError SetVdecChannelDescBitDepth(aclvdecChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t bitDepth = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&bitDepth),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return aclvdecSetChannelDescBitDepth(channelDesc, bitDepth);
    }

    aclError SetDvppChannelDescMatrix(acldvppChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&matrixFormat),
                                           sizeof(acldvppCscMatrix)), "memcpy value failed");
        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        return imageProcessor->acldvppSetChannelDescMatrix(channelDesc, matrixFormat);
    }

    aclError SetDvppChannelDescMode(acldvppChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t descMode = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&descMode),
                                                                sizeof(uint32_t)), "memcpy value failed");
        return acldvppSetChannelDescMode(channelDesc, descMode);
    }

    aclError SetDvppChannelDescHeight(acldvppChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t height = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&height),
                                                                sizeof(uint32_t)), "memcpy value failed");
        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        return imageProcessor->acldvppSetChannelDescHeight(channelDesc, height);
    }

    aclError SetDvppChannelDescWidth(acldvppChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        uint32_t width = 0U;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&width),
                                                                sizeof(uint32_t)), "memcpy value failed");

        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        return imageProcessor->acldvppSetChannelDescWidth(channelDesc, width);
    }

    aclError SetDvppJpegdPrecisionMode(acldvppChannelDesc *const channelDesc, const size_t length,
        const void *const param)
    {
        acldvppJpegdPrecisionMode precisionMode = ACL_YUVOUT_ALIGN_DOWN;
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(param, length, static_cast<void *>(&precisionMode),
            sizeof(acldvppJpegdPrecisionMode)), "memcpy value failed");

        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        return imageProcessor->acldvppSetJpegdPrecisionMode(channelDesc, precisionMode);
    }

    aclError GetVdecChannelDescMatrix(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
        ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
        acldvppCscMatrix matrixFormat;
        aclError ret = videoProcessor->aclvdecGetChannelDescMatrix(channelDesc, matrixFormat);
        if (ret != ACL_SUCCESS) {
            ACL_LOG_INNER_ERROR("[Get][Matrix]get csc matrix failed, ret = %d.", ret);
            return ret;
        }
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&matrixFormat),
            sizeof(acldvppCscMatrix), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppCscMatrix);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescOutMode(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t outMode = aclvdecGetChannelDescOutMode(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&outMode), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescThreadId(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint64_t threadId = aclvdecGetChannelDescThreadId(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&threadId), sizeof(uint64_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint64_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescCallback(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const aclvdecCallback callback = aclvdecGetChannelDescCallback(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&callback), sizeof(size_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(size_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescChannelId(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t channelId = aclvdecGetChannelDescChannelId(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&channelId), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescEnType(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const acldvppStreamFormat enType = aclvdecGetChannelDescEnType(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&enType),
            sizeof(acldvppStreamFormat), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppStreamFormat);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescOutPicFormat(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const acldvppPixelFormat picFormat = aclvdecGetChannelDescOutPicFormat(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picFormat),
            sizeof(acldvppPixelFormat), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppPixelFormat);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescOutPicWidth(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t picWidth = aclvdecGetChannelDescOutPicWidth(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picWidth), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescOutPicHeight(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t picHeight = aclvdecGetChannelDescOutPicHeight(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&picHeight), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescRefFrameNum(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t refFrameNum = aclvdecGetChannelDescRefFrameNum(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&refFrameNum),
            sizeof(uint32_t), param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetVdecChannelDescBitDepth(const aclvdecChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint32_t bitDepth = aclvdecGetChannelDescBitDepth(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&bitDepth), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetDvppChannelDescMatrix(const acldvppChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        acldvppCscMatrix matrixFormat;
        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        aclError ret = imageProcessor->acldvppGetChannelDescMatrix(channelDesc, matrixFormat);
        if (ret != ACL_SUCCESS) {
            ACL_LOG_INNER_ERROR("[Get][Matrix]get csc matrix failed, ret = %d.", ret);
            return ret;
        }
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&matrixFormat),
            sizeof(acldvppCscMatrix), param, length), "memcpy value failed");
        *paramRetSize = sizeof(acldvppCscMatrix);
        return ACL_SUCCESS;
    }

    aclError GetDvppChannelDescChannelId(const acldvppChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        const uint64_t channelId = acldvppGetChannelDescChannelId(channelDesc);
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&channelId), sizeof(uint64_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint64_t);
        return ACL_SUCCESS;
    }

    aclError GetDvppChannelDescHeight(const acldvppChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        uint32_t height = 0U;
        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        aclError ret = imageProcessor->acldvppGetChannelDescHeight(channelDesc, height);
        if (ret != ACL_SUCCESS) {
            ACL_LOG_INNER_ERROR("[Get][Matrix]get height failed, errorCode = %d.", ret);
            return ret;
        }
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&height), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    aclError GetDvppChannelDescWidth(const acldvppChannelDesc *const channelDesc, const size_t length,
        size_t *const paramRetSize, void *const param)
    {
        uint32_t width = 0U;
        const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
        ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
        aclError ret = imageProcessor->acldvppGetChannelDescWidth(channelDesc, width);
        if (ret != ACL_SUCCESS) {
            ACL_LOG_INNER_ERROR("[Get][Matrix]get width failed, errorCode = %d.", ret);
            return ret;
        }
        ACL_REQUIRES_OK_WITH_INNER_MESSAGE(CopyChannelDescParam(static_cast<const void *>(&width), sizeof(uint32_t),
                                                                param, length), "memcpy value failed");
        *paramRetSize = sizeof(uint32_t);
        return ACL_SUCCESS;
    }

    using SetVencParamFunc = aclError (*)(aclvencChannelDesc *, size_t, const void *);
    std::map<aclvencChannelDescParamType, SetVencParamFunc> g_vencSetParamFuncMap = {
        {ACL_VENC_THREAD_ID_UINT64, &SetVencChannelDescThreadId},
        {ACL_VENC_CALLBACK_PTR, &SetVencChannelDescCallback},
        {ACL_VENC_PIXEL_FORMAT_UINT32, &SetVencChannelDescPicFormat},
        {ACL_VENC_ENCODE_TYPE_UINT32, &SetVencChannelDescEnType},
        {ACL_VENC_PIC_WIDTH_UINT32, &SetVencChannelDescPicWidth},
        {ACL_VENC_PIC_HEIGHT_UINT32, &SetVencChannelDescPicHeight},
        {ACL_VENC_KEY_FRAME_INTERVAL_UINT32, &SetVencChannelDescKeyFrameInterval},
        {ACL_VENC_BUF_ADDR_PTR, &SetVencChannelDescBufAddr},
        {ACL_VENC_BUF_SIZE_UINT32, &SetVencChannelDescBufSize},
        {ACL_VENC_RC_MODE_UINT32, &SetVencChannelDescRcMode},
        {ACL_VENC_SRC_RATE_UINT32, &SetVencChannelDescSrcRate},
        {ACL_VENC_MAX_BITRATE_UINT32, &SetVencChannelDescMaxBitRate},
        {ACL_VENC_MAX_IP_PROP_UINT32, &SetVencChannelDescIpProp}
    };

    using GetVencParamFunc = aclError (*)(const aclvencChannelDesc *, size_t, size_t *, void *);
    std::map<aclvencChannelDescParamType, GetVencParamFunc> g_vencGetParamFuncMap = {
        {ACL_VENC_THREAD_ID_UINT64, &GetVencChannelDescThreadId},
        {ACL_VENC_CALLBACK_PTR, &GetVencChannelDescCallback},
        {ACL_VENC_PIXEL_FORMAT_UINT32, &GetVencChannelDescPicFormat},
        {ACL_VENC_ENCODE_TYPE_UINT32, &GetVencChannelDescEnType},
        {ACL_VENC_PIC_WIDTH_UINT32, &GetVencChannelDescPicWidth},
        {ACL_VENC_PIC_HEIGHT_UINT32, &GetVencChannelDescPicHeight},
        {ACL_VENC_KEY_FRAME_INTERVAL_UINT32, &GetVencChannelDescKeyFrameInterval},
        {ACL_VENC_BUF_ADDR_PTR, &GetVencChannelDescBufAddr},
        {ACL_VENC_BUF_SIZE_UINT32, &GetVencChannelDescBufSize},
        {ACL_VENC_RC_MODE_UINT32, &GetVencChannelDescRcMode},
        {ACL_VENC_SRC_RATE_UINT32, &GetVencChannelDescSrcRate},
        {ACL_VENC_MAX_BITRATE_UINT32, &GetVencChannelDescMaxBitRate},
        {ACL_VENC_MAX_IP_PROP_UINT32, &GetVencChannelDescIpProp}
    };

    using SetVdecParamFunc = aclError (*)(aclvdecChannelDesc *, size_t, const void *);
    std::map<aclvdecChannelDescParamType, SetVdecParamFunc> g_vdecSetParamFuncMap = {
        {ACL_VDEC_CSC_MATRIX_UINT32, &SetVdecChannelDescMatrix},
        {ACL_VDEC_OUT_MODE_UINT32, &SetVdecChannelDescOutMode},
        {ACL_VDEC_THREAD_ID_UINT64, &SetVdecChannelDescThreadId},
        {ACL_VDEC_CALLBACK_PTR, &SetVdecChannelDescCallback},
        {ACL_VDEC_CHANNEL_ID_UINT32, &SetVdecChannelDescChannelId},
        {ACL_VDEC_ENCODE_TYPE_UINT32, &SetVdecChannelDescEnType},
        {ACL_VDEC_OUT_PIC_FORMAT_UINT32, &SetVdecChannelDescOutPicFormat},
        {ACL_VDEC_OUT_PIC_WIDTH_UINT32, &SetVdecChannelDescOutPicWidth},
        {ACL_VDEC_OUT_PIC_HEIGHT_UINT32, &SetVdecChannelDescOutPicHeight},
        {ACL_VDEC_REF_FRAME_NUM_UINT32, &SetVdecChannelDescRefFrameNum},
        {ACL_VDEC_BIT_DEPTH_UINT32, &SetVdecChannelDescBitDepth}
    };

    using GetVdecParamFunc = aclError (*)(const aclvdecChannelDesc *, size_t, size_t *, void *);
    std::map<aclvdecChannelDescParamType, GetVdecParamFunc> g_vdecGetParamFuncMap = {
        {ACL_VDEC_CSC_MATRIX_UINT32, &GetVdecChannelDescMatrix},
        {ACL_VDEC_OUT_MODE_UINT32, &GetVdecChannelDescOutMode},
        {ACL_VDEC_THREAD_ID_UINT64, &GetVdecChannelDescThreadId},
        {ACL_VDEC_CALLBACK_PTR, &GetVdecChannelDescCallback},
        {ACL_VDEC_CHANNEL_ID_UINT32, &GetVdecChannelDescChannelId},
        {ACL_VDEC_ENCODE_TYPE_UINT32, &GetVdecChannelDescEnType},
        {ACL_VDEC_OUT_PIC_FORMAT_UINT32, &GetVdecChannelDescOutPicFormat},
        {ACL_VDEC_OUT_PIC_WIDTH_UINT32, &GetVdecChannelDescOutPicWidth},
        {ACL_VDEC_OUT_PIC_HEIGHT_UINT32, &GetVdecChannelDescOutPicHeight},
        {ACL_VDEC_REF_FRAME_NUM_UINT32, &GetVdecChannelDescRefFrameNum},
        {ACL_VDEC_BIT_DEPTH_UINT32, &GetVdecChannelDescBitDepth}
    };

    using SetDvppParamFunc = aclError (*)(acldvppChannelDesc *, size_t, const void *);
    std::map<acldvppChannelDescParamType, SetDvppParamFunc> g_dvppSetParamFuncMap = {
        {ACL_DVPP_CSC_MATRIX_UINT32, &SetDvppChannelDescMatrix},
        {ACL_DVPP_MODE_UINT32, &SetDvppChannelDescMode},
        {ACL_DVPP_CHANNEL_HEIGHT_UINT32, &SetDvppChannelDescHeight},
        {ACL_DVPP_CHANNEL_WIDTH_UINT32, &SetDvppChannelDescWidth},
        {ACL_DVPP_JPEGD_PRECISION_MODE_ENUM, &SetDvppJpegdPrecisionMode}
    };

    using GetDvppParamFunc = aclError (*)(const acldvppChannelDesc *, size_t, size_t *, void *);
    std::map<acldvppChannelDescParamType, GetDvppParamFunc> g_dvppGetParamFuncMap = {
        {ACL_DVPP_CSC_MATRIX_UINT32, &GetDvppChannelDescMatrix},
        {ACL_DVPP_CHANNEL_ID_UINT64, &GetDvppChannelDescChannelId},
        {ACL_DVPP_CHANNEL_HEIGHT_UINT32, &GetDvppChannelDescHeight},
        {ACL_DVPP_CHANNEL_WIDTH_UINT32, &GetDvppChannelDescWidth}
    };
}

aclError acldvppMalloc(void **devPtr, size_t size)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppMalloc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_DVPP_MALLOC_FREE);
    ACL_LOG_DEBUG("start to execute acldvppMalloc, size = %zu", size);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(devPtr);
    size_t alignedSize;
    ACL_REQUIRES_OK(GetAlignedSizeForDvpp(size, alignedSize));

    const rtError_t rtErr = rtDvppMalloc(devPtr, alignedSize, acl::ACL_MODE_ID_U16);
    if (rtErr != RT_ERROR_NONE) {
        ACL_LOG_CALL_ERROR("alloc device memory for dvpp failed, errorCode = %d", rtErr);
        return ACL_GET_ERRCODE_RTS(rtErr);
    }
    ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_DVPP_MALLOC_FREE);
    return ACL_SUCCESS;
}

aclError acldvppFree(void *devPtr)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppFree);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_DVPP_MALLOC_FREE);
    ACL_LOG_DEBUG("start to execute acldvppFree");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(devPtr);

    const rtError_t rtErr = rtDvppFree(devPtr);
    if (rtErr != RT_ERROR_NONE) {
        ACL_LOG_CALL_ERROR("free device memory for dvpp failed, errorCode = %d", rtErr);
        return ACL_GET_ERRCODE_RTS(rtErr);
    }
    ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_DVPP_MALLOC_FREE);
    return ACL_SUCCESS;
}

acldvppPicDesc *acldvppCreatePicDesc()
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreatePicDesc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_PIC_DESC);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    const auto aclPicDesc = imageProcessor->acldvppCreatePicDesc();
    if (aclPicDesc != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_PIC_DESC);
    }
    return aclPicDesc;
}

aclError acldvppDestroyPicDesc(acldvppPicDesc *picDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyPicDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_PIC_DESC);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    const aclError aclRet = imageProcessor->acldvppDestroyPicDesc(picDesc);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_PIC_DESC);
    }
    return aclRet;
}

aclError acldvppSetPicDescData(acldvppPicDesc *picDesc, void *dataDev)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescData");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataDev);
    picDesc->dvppPicDesc.data = reinterpret_cast<uintptr_t>(dataDev);
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescSize(acldvppPicDesc *picDesc, uint32_t size)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescSize");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.size = size;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescFormat(acldvppPicDesc *picDesc, acldvppPixelFormat format)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescFormat");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.format = format;
    // 0x0001 represents that picture format is used first.
    picDesc->dvppPicDesc.bitMap |= 0x0001U;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescWidth(acldvppPicDesc *picDesc, uint32_t width)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescWidth");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.width = width;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescHeight(acldvppPicDesc *picDesc, uint32_t height)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescHeight");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.height = height;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescWidthStride(acldvppPicDesc *picDesc, uint32_t widthStride)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescWidthStride");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.widthStride = widthStride;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescHeightStride(acldvppPicDesc *picDesc, uint32_t heightStride)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescHeightStride");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.heightStride = heightStride;
    return ACL_SUCCESS;
}

aclError acldvppSetPicDescRetCode(acldvppPicDesc *picDesc, uint32_t retCode)
{
    ACL_LOG_DEBUG("start to execute acldvppSetPicDescRetCode");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(picDesc);
    picDesc->dvppPicDesc.retCode = retCode;
    return ACL_SUCCESS;
}

void *acldvppGetPicDescData(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescData");
    if (picDesc == nullptr) {
        return nullptr;
    }
    return reinterpret_cast<void *>(static_cast<uintptr_t>(picDesc->dvppPicDesc.data));
}

uint32_t acldvppGetPicDescSize(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescSize");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.size;
}

acldvppPixelFormat acldvppGetPicDescFormat(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescFormat");
    if (picDesc == nullptr) {
        return PIXEL_FORMAT_YUV_400;
    }
    return static_cast<acldvppPixelFormat>(picDesc->dvppPicDesc.format);
}

uint32_t acldvppGetPicDescWidth(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescWidth");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.width;
}

uint32_t acldvppGetPicDescHeight(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescHeight");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.height;
}

uint32_t acldvppGetPicDescWidthStride(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescWidthStride");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.widthStride;
}

uint32_t acldvppGetPicDescHeightStride(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescHeightStride");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.heightStride;
}

uint32_t acldvppGetPicDescRetCode(const acldvppPicDesc *picDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetPicDescRetCode");
    if (picDesc == nullptr) {
        return 0U; // default 0
    }
    return picDesc->dvppPicDesc.retCode;
}

acldvppRoiConfig *acldvppCreateRoiConfig(uint32_t left,
                                         uint32_t right,
                                         uint32_t top,
                                         uint32_t bottom)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreateRoiConfig);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_ROI_CONFIG);
    if ((left > static_cast<uint32_t>(UINT16_MAX)) || (right > static_cast<uint32_t>(UINT16_MAX)) ||
        (top > static_cast<uint32_t>(UINT16_MAX)) || (bottom > static_cast<uint32_t>(UINT16_MAX))) {
        ACL_LOG_ERROR("param great than UINT16_MAX, left=%u, right=%u, top=%u, bottom=%u.",
            left, right, top, bottom);
        return nullptr;
    }
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    const auto aclRoiConfig = imageProcessor->acldvppCreateRoiConfig(left, right, top, bottom);
    if (aclRoiConfig != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_ROI_CONFIG);
    }
    return aclRoiConfig;
}

aclError acldvppDestroyRoiConfig(acldvppRoiConfig *roiConfig)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyRoiConfig);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_ROI_CONFIG);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    const aclError aclRet = imageProcessor->acldvppDestroyRoiConfig(roiConfig);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_ROI_CONFIG);
    }
    return aclRet;
}

aclError acldvppSetRoiConfigLeft(acldvppRoiConfig *config, uint32_t left)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(config);
    if (left > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("param great than UINT16_MAX.");
        const std::string leftStr = std::to_string(left);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", leftStr.c_str(), "great than UINT16_MAX"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    config->dvppRoiConfig.leftOffset = static_cast<uint16_t>(left);
    return ACL_SUCCESS;
}

aclError acldvppSetRoiConfigRight(acldvppRoiConfig *config, uint32_t right)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(config);
    if (right > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("param great than UINT16_MAX.");
        return ACL_ERROR_INVALID_PARAM;
    }
    config->dvppRoiConfig.rightOffset = static_cast<uint16_t>(right);
    return ACL_SUCCESS;
}

aclError acldvppSetRoiConfigTop(acldvppRoiConfig *config, uint32_t top)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(config);
    if (top > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("param great than UINT16_MAX.");
        return ACL_ERROR_INVALID_PARAM;
    }
    config->dvppRoiConfig.upOffset = static_cast<uint16_t>(top);
    return ACL_SUCCESS;
}

aclError acldvppSetRoiConfigBottom(acldvppRoiConfig *config, uint32_t bottom)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(config);
    if (bottom > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("param great than UINT16_MAX.");
        return ACL_ERROR_INVALID_PARAM;
    }
    config->dvppRoiConfig.downOffset = static_cast<uint16_t>(bottom);
    return ACL_SUCCESS;
}

aclError acldvppSetRoiConfig(acldvppRoiConfig *config,
                             uint32_t left,
                             uint32_t right,
                             uint32_t top,
                             uint32_t bottom)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(config);
    if ((left > static_cast<uint32_t>(UINT16_MAX)) || (right > static_cast<uint32_t>(UINT16_MAX)) ||
        (top > static_cast<uint32_t>(UINT16_MAX)) || (bottom > static_cast<uint32_t>(UINT16_MAX))) {
        ACL_LOG_ERROR("param great than UINT16_MAX, left=%u, right=%u, top=%u, bottom=%u.",
            left, right, top, bottom);
        return ACL_ERROR_INVALID_PARAM;
    }
    config->dvppRoiConfig.leftOffset = static_cast<uint16_t>(left);
    config->dvppRoiConfig.rightOffset = static_cast<uint16_t>(right);
    config->dvppRoiConfig.upOffset = static_cast<uint16_t>(top);
    config->dvppRoiConfig.downOffset = static_cast<uint16_t>(bottom);
    return ACL_SUCCESS;
}

acldvppJpegeConfig *acldvppCreateJpegeConfig()
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreateJpegeConfig);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_JPEGE_CONFIG);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    const auto aclJpegeConfig = imageProcessor->acldvppCreateJpegeConfig();
    if (aclJpegeConfig != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_JPEGE_CONFIG);
    }
    return aclJpegeConfig;
}

aclError acldvppDestroyJpegeConfig(acldvppJpegeConfig *jpegeConfig)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyJpegeConfig);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_JPEGE_CONFIG);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    const aclError aclRet = imageProcessor->acldvppDestroyJpegeConfig(jpegeConfig);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_JPEGE_CONFIG);
    }
    return aclRet;
}

aclError acldvppSetJpegeConfigLevel(acldvppJpegeConfig *jpegeConfig, uint32_t level)
{
    ACL_LOG_DEBUG("start to execute acldvppSetJpegeConfigLevel");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(jpegeConfig);
    jpegeConfig->dvppJpegeConfig.level = level;
    return ACL_SUCCESS;
}

uint32_t acldvppGetJpegeConfigLevel(const acldvppJpegeConfig *jpegeConfig)
{
    ACL_LOG_DEBUG("start to execute acldvppGetJpegeConfigLevel");
    if (jpegeConfig == nullptr) {
        ACL_LOG_ERROR("jpegeConfig is null");
        return 0U;  // default 0
    }
    return jpegeConfig->dvppJpegeConfig.level;
}

acldvppResizeConfig *acldvppCreateResizeConfig()
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreateResizeConfig);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_RESIZE_CONFIG);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    const auto aclResizeConfig = imageProcessor->acldvppCreateResizeConfig();
    if (aclResizeConfig != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_RESIZE_CONFIG);
    }
    return aclResizeConfig;
}

aclError acldvppDestroyResizeConfig(acldvppResizeConfig *resizeConfig)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyResizeConfig);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_RESIZE_CONFIG);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    const aclError aclRet = imageProcessor->acldvppDestroyResizeConfig(resizeConfig);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_RESIZE_CONFIG);
    }
    return aclRet;
}

aclError acldvppSetResizeConfigInterpolation(acldvppResizeConfig *resizeConfig, uint32_t interpolation)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppSetResizeConfigInterpolation(resizeConfig, interpolation);
}

uint32_t acldvppGetResizeConfigInterpolation(const acldvppResizeConfig *resizeConfig)
{
    ACL_LOG_DEBUG("start to execute acldvppGetResizeConfigInterpolation");
    if (resizeConfig == nullptr) {
        ACL_LOG_ERROR("resizeConfig was nullptr.");
        return 0U;
    }

    return resizeConfig->dvppResizeConfig.interpolation;
}

aclError acldvppSetChannelDescMode(acldvppChannelDesc *channelDesc, uint32_t mode)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppSetChannelDescMode(channelDesc, mode);
}

acldvppChannelDesc *acldvppCreateChannelDesc()
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreateChannelDesc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_CHANNEL_DESC);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    const auto aclChannelDesc = imageProcessor->acldvppCreateChannelDesc();
    if (aclChannelDesc != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_CHANNEL_DESC);
    }
    return aclChannelDesc;
}

aclError acldvppDestroyChannelDesc(acldvppChannelDesc *channelDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyChannelDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_CHANNEL_DESC);
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    const aclError aclRet = imageProcessor->acldvppDestroyChannelDesc(channelDesc);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_CHANNEL_DESC);
    }
    return aclRet;
}

uint64_t acldvppGetChannelDescChannelId(const acldvppChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetChannelDescChannelId");
    if (channelDesc == nullptr) {
        return 0U;
    }
    return channelDesc->channelIndex;
}

aclvdecChannelDesc *aclvdecCreateChannelDesc()
{
    ACL_PROFILING_REG(acl::AclProfType::AclvdecCreateChannelDesc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_CHANNEL_DESC);
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(videoProcessor);
    const auto aclChannelDesc = videoProcessor->aclvdecCreateChannelDesc();
    if (aclChannelDesc != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_CHANNEL_DESC);
    }
    return aclChannelDesc;
}

aclError aclvdecDestroyChannelDesc(aclvdecChannelDesc *channelDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AclvdecDestroyChannelDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_CHANNEL_DESC);
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    const aclError aclRet = videoProcessor->aclvdecDestroyChannelDesc(channelDesc);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_CHANNEL_DESC);
    }
    return aclRet;
}

aclError aclvdecSetChannelDescOutMode(aclvdecChannelDesc *channelDesc, uint32_t outMode)
{
    ACL_LOG_DEBUG("start to execute aclvdecSetChannelDescOutMode");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    // outMode support 0 : default mode, 1 : fast mode
    if (outMode > 1U) {
        ACL_LOG_ERROR("unsupported outMode, outMode = %u", outMode);
        return ACL_ERROR_INVALID_PARAM;
    }

    channelDesc->vdecDesc.outMode = outMode;
    return ACL_SUCCESS;
}

aclError aclvdecSetChannelDescThreadId(aclvdecChannelDesc *channelDesc, uint64_t threadId)
{
    ACL_LOG_DEBUG("start to execute aclvdecSetChannelDescThreadId");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }

    channelDesc->threadId = threadId;
    return ACL_SUCCESS;
}

aclError aclvdecSetChannelDescCallback(aclvdecChannelDesc *channelDesc, aclvdecCallback callback)
{
    ACL_LOG_DEBUG("start to execute aclvdecSetChannelDescCallback");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }

    if (callback == nullptr) {
        ACL_LOG_ERROR("aclvdecCallback is null.");
        return ACL_ERROR_INVALID_PARAM;
    }

    channelDesc->callback = callback;
    return ACL_SUCCESS;
}

uint32_t aclvdecGetChannelDescChannelId(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescChannelId");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return 0U; // default 0
    }
    return channelDesc->vdecDesc.channelId;
}

uint64_t aclvdecGetChannelDescThreadId(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescThreadId");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return 0U; // default 0
    }
    return channelDesc->threadId;
}

aclvdecCallback aclvdecGetChannelDescCallback(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescCallback");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return nullptr; // default null
    }
    return channelDesc->callback;
}

acldvppStreamFormat aclvdecGetChannelDescEnType(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescEnType");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return H265_MAIN_LEVEL;
    }
    return static_cast<acldvppStreamFormat>(channelDesc->vdecDesc.enType);
}

acldvppPixelFormat aclvdecGetChannelDescOutPicFormat(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescOutPicFormat");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return PIXEL_FORMAT_YUV_400;
    }
    return static_cast<acldvppPixelFormat>(channelDesc->vdecDesc.outPicFormat);
}

uint32_t aclvdecGetChannelDescOutPicWidth(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescOutPicWidth");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return 0U; // default 0
    }
    return channelDesc->vdecDesc.outPicWidth;
}

uint32_t aclvdecGetChannelDescOutPicHeight(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescOutPicHeight");
    if (channelDesc == nullptr) {
        ACL_LOG_ERROR("channelDesc is null");
        return 0U; // default 0
    }
    return channelDesc->vdecDesc.outPicHeight;
}

uint32_t aclvdecGetChannelDescRefFrameNum(const aclvdecChannelDesc *channelDesc)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    if (videoProcessor == nullptr) {
        ACL_LOG_INNER_ERROR("[Check][VideoProcessor]video processor is null.");
        return 0U;
    }
    return videoProcessor->aclvdecGetChannelDescRefFrameNum(channelDesc);
}

acldvppStreamDesc *acldvppCreateStreamDesc()
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppCreateStreamDesc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_STREAM_DESC);
    ACL_LOG_INFO("start to execute acldvppCreateStreamDesc");
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(videoProcessor);
    const auto aclDvppStreamDesc = videoProcessor->acldvppCreateStreamDesc();
    if (aclDvppStreamDesc != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_STREAM_DESC);
    }
    return aclDvppStreamDesc;
}

aclError acldvppDestroyStreamDesc(acldvppStreamDesc *streamDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyStreamDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_STREAM_DESC);
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    const auto aclRet = videoProcessor->acldvppDestroyStreamDesc(streamDesc);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_STREAM_DESC);
    }
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescData(acldvppStreamDesc *streamDesc, void *dataDev)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescData");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(streamDesc);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataDev);
    streamDesc->dvppStreamDesc.data = reinterpret_cast<uintptr_t>(dataDev);
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescSize(acldvppStreamDesc *streamDesc, uint32_t size)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescSize");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    streamDesc->dvppStreamDesc.size = size;
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescFormat(acldvppStreamDesc *streamDesc, acldvppStreamFormat format)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescFormat");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    streamDesc->dvppStreamDesc.format = static_cast<uint32_t>(format);
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescTimestamp(acldvppStreamDesc *streamDesc, uint64_t timestamp)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescTimestamp");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    streamDesc->dvppStreamDesc.timestamp = timestamp;
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescRetCode(acldvppStreamDesc *streamDesc, uint32_t retCode)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescRetCode");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    streamDesc->dvppStreamDesc.retCode = retCode;
    return ACL_SUCCESS;
}

aclError acldvppSetStreamDescEos(acldvppStreamDesc *streamDesc, uint8_t eos)
{
    ACL_LOG_DEBUG("start to execute acldvppSetStreamDescEos");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return ACL_ERROR_INVALID_PARAM;
    }
    // 0: false, 1: true
    streamDesc->dvppStreamDesc.eos = (static_cast<int32_t>(eos) != 0);
    return ACL_SUCCESS;
}

void *acldvppGetStreamDescData(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescData");
    if (streamDesc == nullptr) {
        return nullptr;
    }
    return reinterpret_cast<void *>(static_cast<uintptr_t>(streamDesc->dvppStreamDesc.data));
}

uint32_t acldvppGetStreamDescSize(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescSize");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return 0U; // default 0
    }
    return streamDesc->dvppStreamDesc.size;
}

acldvppStreamFormat acldvppGetStreamDescFormat(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescFormat");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return H265_MAIN_LEVEL;
    }
    return static_cast<acldvppStreamFormat>(streamDesc->dvppStreamDesc.format);
}

uint64_t acldvppGetStreamDescTimestamp(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescTimestamp");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return 0U; // default 0
    }
    return streamDesc->dvppStreamDesc.timestamp;
}

uint32_t acldvppGetStreamDescRetCode(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescRetCode");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return 0U; // default 0
    }
    return streamDesc->dvppStreamDesc.retCode;
}

uint8_t acldvppGetStreamDescEos(const acldvppStreamDesc *streamDesc)
{
    ACL_LOG_DEBUG("start to execute acldvppGetStreamDescEos");
    if (streamDesc == nullptr) {
        ACL_LOG_ERROR("streamDesc is null.");
        return 0U; // default 0
    }
    return (streamDesc->dvppStreamDesc.eos) ? 1U : 0U;
}

aclvdecFrameConfig *aclvdecCreateFrameConfig()
{
    ACL_PROFILING_REG(acl::AclProfType::AclvdecCreateFrameConfig);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_FRAME_CONFIG);
    ACL_LOG_INFO("start to execute aclvdecCreateFrameConfig");
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(videoProcessor);
    const auto aclVdecFrameConfig = videoProcessor->aclvdecCreateFrameConfig();
    if (aclVdecFrameConfig != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_FRAME_CONFIG);
    }
    return aclVdecFrameConfig;
}

aclError aclvdecDestroyFrameConfig(aclvdecFrameConfig *vdecFrameConfig)
{
    ACL_PROFILING_REG(acl::AclProfType::AclvdecDestroyFrameConfig);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_FRAME_CONFIG);
    ACL_LOG_DEBUG("start to execute acldvppSetJpegeConfigLevel");
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    const auto aclRet = videoProcessor->aclvdecDestroyFrameConfig(vdecFrameConfig);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VDEC_FRAME_CONFIG);
    }
    return aclRet;
}

aclvencChannelDesc *aclvencCreateChannelDesc()
{
    ACL_PROFILING_REG(acl::AclProfType::AclvencCreateChannelDesc);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_CHANNEL_DESC);
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(videoProcessor);
    const auto aclChannelDesc = videoProcessor->aclvencCreateChannelDesc();
    if (aclChannelDesc != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_CHANNEL_DESC);
    }
    return aclChannelDesc;
}

aclError aclvencDestroyChannelDesc(aclvencChannelDesc *channelDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AclvencDestroyChannelDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_CHANNEL_DESC);
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    const aclError aclRet = videoProcessor->aclvencDestroyChannelDesc(channelDesc);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_CHANNEL_DESC);
    }
    return aclRet;
}

aclvencFrameConfig *aclvencCreateFrameConfig()
{
    ACL_PROFILING_REG(acl::AclProfType::AclvencCreateFrameConfig);
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_FRAME_CONFIG);
    ACL_LOG_INFO("start to execute aclvencCreateFrameConfig");
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(videoProcessor);
    const auto aclFrameConfig = videoProcessor->aclvencCreateFrameConfig();
    if (aclFrameConfig != nullptr) {
        ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_FRAME_CONFIG);
    }
    return aclFrameConfig;
}

aclError aclvencDestroyFrameConfig(aclvencFrameConfig *config)
{
    ACL_PROFILING_REG(acl::AclProfType::AclvencDestroyFrameConfig);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_FRAME_CONFIG);
    ACL_LOG_DEBUG("start to execute aclvencDestroyFrameConfig");
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    const auto aclRet = videoProcessor->aclvencDestroyFrameConfig(config);
    if (aclRet == ACL_SUCCESS) {
        ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_VENC_FRAME_CONFIG);
    }
    return aclRet;
}

aclError aclvencSetChannelDescParam(aclvencChannelDesc *channelDesc,
    aclvencChannelDescParamType paramType, size_t length, const void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_vencSetParamFuncMap.find(paramType) == g_vencSetParamFuncMap.end()) {
        ACL_LOG_ERROR("invalid venc channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        const std::string paramTypeStr = std::to_string(static_cast<int32_t>(paramType));
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"parameter type", paramTypeStr.c_str(), ""};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_vencSetParamFuncMap[paramType](channelDesc, length, param);
}

aclError aclvdecSetChannelDescParam(aclvdecChannelDesc *channelDesc,
    aclvdecChannelDescParamType paramType, size_t length, const void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_vdecSetParamFuncMap.find(paramType) == g_vdecSetParamFuncMap.end()) {
        ACL_LOG_ERROR("[Check][Paramtype]invalid vdec channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        const std::string paramTypeStr = std::to_string(static_cast<int32_t>(paramType));
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"parameter type", paramTypeStr.c_str(), ""};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U);
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_vdecSetParamFuncMap[paramType](channelDesc, length, param);
}

aclError acldvppSetChannelDescParam(acldvppChannelDesc *channelDesc,
    acldvppChannelDescParamType paramType, size_t length, const void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_dvppSetParamFuncMap.find(paramType) == g_dvppSetParamFuncMap.end()) {
        ACL_LOG_ERROR("[Check][Paramtype]invalid dvpp channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        const std::string paramTypeStr = std::to_string(static_cast<int32_t>(paramType));
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"parameter type", paramTypeStr.c_str(), ""};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U);
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_dvppSetParamFuncMap[paramType](channelDesc, length, param);
}

aclError aclvdecGetChannelDescParam(const aclvdecChannelDesc *channelDesc,
                                    aclvdecChannelDescParamType paramType,
                                    size_t length,
                                    size_t *paramRetSize,
                                    void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(channelDesc);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(paramRetSize);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_vdecGetParamFuncMap.find(paramType) == g_vdecGetParamFuncMap.end()) {
        ACL_LOG_ERROR("[Check][Paramtype]invalid vdec channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        const std::string paramTypeStr = std::to_string(static_cast<int32_t>(paramType));
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"parameter type", paramTypeStr.c_str(), ""};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U);
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_vdecGetParamFuncMap[paramType](channelDesc, length, paramRetSize, param);
}

aclError acldvppGetChannelDescParam(const acldvppChannelDesc *channelDesc,
                                    acldvppChannelDescParamType paramType,
                                    size_t length,
                                    size_t *paramRetSize,
                                    void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_dvppGetParamFuncMap.find(paramType) == g_dvppGetParamFuncMap.end()) {
        ACL_LOG_ERROR("[Check][Paramtype]invalid dvpp channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        const std::string paramTypeStr = std::to_string(static_cast<int32_t>(paramType));
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"parameter type", paramTypeStr.c_str(), ""};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U);
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_dvppGetParamFuncMap[paramType](channelDesc, length, paramRetSize, param);
}

aclError aclvencGetChannelDescParam(const aclvencChannelDesc *channelDesc,
    aclvencChannelDescParamType paramType, size_t length, size_t *paramRetSize, void *param)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(channelDesc);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(paramRetSize);
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
    if (g_vencGetParamFuncMap.find(paramType) == g_vencGetParamFuncMap.end()) {
        ACL_LOG_ERROR("invalid venc channelDesc parameter type %d.", static_cast<int32_t>(paramType));
        return ACL_ERROR_INVALID_PARAM;
    }
    return g_vencGetParamFuncMap[paramType](channelDesc, length, paramRetSize, param);
}

acldvppBatchPicDesc *acldvppCreateBatchPicDesc(uint32_t batchSize)
{
    ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_BATCH_PIC_DESC);
    // dvpp kernel process max pictures number is 128
    if ((batchSize == 0U) || (batchSize > BATCH_MAX_SIZE)) {
        ACL_LOG_ERROR("[Check][batchSize]param batchSize is 0 or greater than %u, "
            "batch size = %u.", BATCH_MAX_SIZE, batchSize);
        const std::string batchSizeStr = std::to_string(batchSize);
        const std::string errMsg = acl::AclErrorLogManager::FormatStr("is 0 or greater than %u", BATCH_MAX_SIZE);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"batchSize", batchSizeStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG, argList, argVal, 3U);
        return nullptr;
    }

    // DvppPicDesc dvppPicDescs[1] in struct acldvppBatchPicDesc, so batchSize - 1
    const size_t hostSize = sizeof(acldvppBatchPicDesc) + (sizeof(aicpu::dvpp::DvppPicDesc) *
        static_cast<size_t>(batchSize - 1U));
    const size_t pageSize = mmGetPageSize();
    void *aclBatchPicAddr = mmAlignMalloc(hostSize, pageSize);
    ACL_REQUIRES_NOT_NULL_RET_NULL(aclBatchPicAddr);
    acldvppBatchPicDesc *const batchPicDesc = new (aclBatchPicAddr)acldvppBatchPicDesc;
    batchPicDesc->dvppBatchPicDescs.batchSize = batchSize;
    batchPicDesc->aclDvppPicDescs = new (std::nothrow)acldvppPicDesc[batchSize];
    if (batchPicDesc->aclDvppPicDescs == nullptr) {
        ACL_ALIGN_FREE(aclBatchPicAddr);
        ACL_LOG_INNER_ERROR("[Create][dvppPicDesc]create acldvppPicDesc failed. batch size=%u.", batchSize);
        return nullptr;
    }

    // alloc device memory
    void *devPtr = nullptr;
    const size_t devSize = (sizeof(aicpu::dvpp::DvppPicDesc) * batchSize) + sizeof(uint32_t);
    const uint32_t flags = RT_MEMORY_DEFAULT | RT_MEMORY_POLICY_DEFAULT_PAGE_ONLY;
    const aclError ret = rtMalloc(&devPtr, devSize, flags, acl::ACL_MODE_ID_U16);
    if (ret != ACL_SUCCESS) {
        ACL_LOG_ERROR("malloc device memory failed, errorCode = %d. batch size=%u.", ret, batchSize);
        ACL_DELETE_ARRAY_AND_SET_NULL(batchPicDesc->aclDvppPicDescs);
        ACL_ALIGN_FREE(aclBatchPicAddr);
        return nullptr;
    }
    size_t offset = sizeof(uint32_t);
    for (uint32_t i = 0U; i < batchSize; ++i) {
        batchPicDesc->aclDvppPicDescs[i].dataBuffer.data =
            reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(devPtr) + offset);
        batchPicDesc->aclDvppPicDescs[i].dataBuffer.length = sizeof(aicpu::dvpp::DvppPicDesc);
        offset += sizeof(aicpu::dvpp::DvppPicDesc);
    }
    batchPicDesc->dataBuffer.data = devPtr;
    batchPicDesc->dataBuffer.length = devSize;
    ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_BATCH_PIC_DESC);
    return batchPicDesc;
}

acldvppPicDesc *acldvppGetPicDesc(acldvppBatchPicDesc *batchPicDesc, uint32_t index)
{
    if (batchPicDesc == nullptr) {
        ACL_LOG_ERROR("param batchPicDesc is nullptr.");
        return nullptr;
    }

    if (index >= batchPicDesc->dvppBatchPicDescs.batchSize) {
        ACL_LOG_ERROR("[Check][Index]index Out of bounds. index=%u, but batchsize=%u.", index,
                      batchPicDesc->dvppBatchPicDescs.batchSize);
        const std::string indexStr = std::to_string(index);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", indexStr.c_str(), "index Out of bounds"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return nullptr;
    }

    return &(batchPicDesc->aclDvppPicDescs[index]);
}

aclError acldvppDestroyBatchPicDesc(acldvppBatchPicDesc *batchPicDesc)
{
    ACL_PROFILING_REG(acl::AclProfType::AcldvppDestroyBatchPicDesc);
    ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_BATCH_PIC_DESC);
    if (batchPicDesc != nullptr) {
        acl::dvpp::FreeDeviceBuffer(batchPicDesc->dataBuffer);
        ACL_DELETE_ARRAY_AND_SET_NULL(batchPicDesc->aclDvppPicDescs);
        ACL_ALIGN_FREE(batchPicDesc);
    }

    ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DVPP_BATCH_PIC_DESC);
    return ACL_SUCCESS;
}

acldvppLutMap *acldvppCreateLutMap()
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    return imageProcessor->acldvppCreateLutMap();
}

aclError acldvppDestroyLutMap(acldvppLutMap *lutMap)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppDestroyLutMap(lutMap);
}

uint32_t acldvppGetLutMapDims(const acldvppLutMap *lutMap)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    if (imageProcessor == nullptr) {
        ACL_LOG_INNER_ERROR("[Check][ImageProcessor]image processor is null.");
        return 0U;
    }
    return imageProcessor->acldvppGetLutMapDims(lutMap);
}

aclError acldvppGetLutMapData(const acldvppLutMap *lutMap, uint32_t dim, uint8_t **data, uint32_t *len)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppGetLutMapData(lutMap, dim, data, len);
}

uint32_t aclvdecGetChannelDescOutMode(const aclvdecChannelDesc *channelDesc)
{
    ACL_LOG_DEBUG("start to execute aclvdecGetChannelDescOutMode");
    if (channelDesc == nullptr) {
        ACL_LOG_INNER_ERROR("[Check][Channeldesc]channelDesc is null.");
        return 0U; // default 0
    }

    return channelDesc->vdecDesc.outMode;
}

acldvppBorderConfig *acldvppCreateBorderConfig()
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    return imageProcessor->acldvppCreateBorderConfig();
}

aclError acldvppSetBorderConfigValue(acldvppBorderConfig *borderConfig, uint32_t index, double value)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    if (index >= acl::DVPP_MAKE_BORDER_MAX_COMPONENT) {
        ACL_LOG_ERROR("index[%u] should be smaller than array[%u]", index, acl::DVPP_MAKE_BORDER_MAX_COMPONENT);
        const std::string indexStr = std::to_string(index);
        const std::string errMsg = acl::AclErrorLogManager::FormatStr("should be smaller than array"
            "[%u]", acl::DVPP_MAKE_BORDER_MAX_COMPONENT);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", indexStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }

    borderConfig->dvppBorderConfig.value[index] = value;
    return ACL_SUCCESS;
}

aclError acldvppSetBorderConfigBorderType(acldvppBorderConfig *borderConfig, acldvppBorderType borderType)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    borderConfig->dvppBorderConfig.borderType = static_cast<uint32_t>(borderType);
    return ACL_SUCCESS;
}

aclError acldvppSetBorderConfigTop(acldvppBorderConfig *borderConfig, uint32_t top)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    if (top > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("the param of top[%u] can't be larger than UINT16_MAX[%u]", top, UINT16_MAX);
        const std::string topStr = std::to_string(top);
        const std::string errMsg =
            acl::AclErrorLogManager::FormatStr("can't be larger than UINT16_MAX[%u]", UINT16_MAX);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", topStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    borderConfig->dvppBorderConfig.top = static_cast<uint16_t>(top);
    return ACL_SUCCESS;
}

aclError acldvppSetBorderConfigBottom(acldvppBorderConfig *borderConfig, uint32_t bottom)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    if (bottom > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("the param of bottom[%u] can't be larger than UINT16_MAX[%u]", bottom, UINT16_MAX);
        const std::string bottomStr = std::to_string(bottom);
        const std::string errMsg =
            acl::AclErrorLogManager::FormatStr("can't be larger than UINT16_MAX[%u]", UINT16_MAX);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", bottomStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    borderConfig->dvppBorderConfig.bottom = static_cast<uint16_t>(bottom);
    return ACL_SUCCESS;
}

aclError acldvppSetBorderConfigLeft(acldvppBorderConfig *borderConfig, uint32_t left)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    if (left > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("the param of left[%u] can't be larger than UINT16_MAX[%u]", left, UINT16_MAX);
        const std::string leftStr = std::to_string(left);
        const std::string errMsg = acl::AclErrorLogManager::FormatStr("can't be larger than UINT16_MAX[%u]",
            UINT16_MAX);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"left", leftStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    borderConfig->dvppBorderConfig.left = static_cast<uint16_t>(left);
    return ACL_SUCCESS;
}

aclError acldvppSetBorderConfigRight(acldvppBorderConfig *borderConfig, uint32_t right)
{
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(borderConfig);
    if (right > static_cast<uint32_t>(UINT16_MAX)) {
        ACL_LOG_ERROR("the param of right[%u] can't be larger than UINT16_MAX[%u]", right, UINT16_MAX);
        const std::string rightStr = std::to_string(right);
        const std::string errMsg = acl::AclErrorLogManager::FormatStr("can't be larger than UINT16_MAX[%u]",
            UINT16_MAX);
        const char_t *argList[] = {"param", "value", "reason"};
        const char_t *argVal[] = {"right", rightStr.c_str(), errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG,
            argList, argVal, 3U); // 3 is param num
        return ACL_ERROR_INVALID_PARAM;
    }
    borderConfig->dvppBorderConfig.right = static_cast<uint16_t>(right);
    return ACL_SUCCESS;
}

double acldvppGetBorderConfigValue(const acldvppBorderConfig *borderConfig, uint32_t index)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][Borderconfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return static_cast<float64_t>(-1.0F);
    }
    if (index >= acl::DVPP_MAKE_BORDER_MAX_COMPONENT) {
        ACL_LOG_ERROR("index[%u] should be smaller than array[%u]", index, acl::DVPP_MAKE_BORDER_MAX_COMPONENT);
        // less than 0 is invalid value
        return static_cast<float64_t>(-1.0F);
    }
    return borderConfig->dvppBorderConfig.value[index];
}

acldvppBorderType acldvppGetBorderConfigBorderType(const acldvppBorderConfig *borderConfig)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][Borderconfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return BORDER_CONSTANT;
    }

    return static_cast<acldvppBorderType>(borderConfig->dvppBorderConfig.borderType);
}

uint32_t acldvppGetBorderConfigTop(const acldvppBorderConfig *borderConfig)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][BorderConfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return DVPP_BORDER_CONFIG_INVALID_VALUE;
    }

    return static_cast<uint32_t>(borderConfig->dvppBorderConfig.top);
}

uint32_t acldvppGetBorderConfigBottom(const acldvppBorderConfig *borderConfig)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][BorderConfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return DVPP_BORDER_CONFIG_INVALID_VALUE;
    }

    return static_cast<uint32_t>(borderConfig->dvppBorderConfig.bottom);
}

uint32_t acldvppGetBorderConfigLeft(const acldvppBorderConfig *borderConfig)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][BorderConfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return DVPP_BORDER_CONFIG_INVALID_VALUE;
    }

    return static_cast<uint32_t>(borderConfig->dvppBorderConfig.left);
}

uint32_t acldvppGetBorderConfigRight(const acldvppBorderConfig *borderConfig)
{
    if (borderConfig == nullptr) {
        ACL_LOG_ERROR("[Check][BorderConfig]border config is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"borderConfig"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return DVPP_BORDER_CONFIG_INVALID_VALUE;
    }

    return static_cast<uint32_t>(borderConfig->dvppBorderConfig.right);
}

aclError acldvppDestroyBorderConfig(acldvppBorderConfig *borderConfig)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppDestroyBorderConfig(borderConfig);
}

aclError aclvdecSetChannelDescEnType(aclvdecChannelDesc *channelDesc, acldvppStreamFormat enType)
{
    ACL_LOG_DEBUG("start to execute aclvdecSetChannelDescEnType");
    ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(channelDesc);

    if (enType < H265_MAIN_LEVEL) {
        ACL_LOG_ERROR("unsupported enType, enType = %u", enType);
        const std::string errMsg = acl::AclErrorLogManager::FormatStr("cannot less than %d",
        static_cast<int32_t>(H265_MAIN_LEVEL));
        const char_t *argList[] = {"feature", "reason"};
        const char_t *argVal[] = {"enType", errMsg.c_str()};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::UNSUPPORTED_FEATURE_MSG,
            argList, argVal, 2U);
        return ACL_ERROR_INVALID_PARAM;
    }

    channelDesc->vdecDesc.enType = enType;
    return ACL_SUCCESS;
}

aclError aclvdecSetChannelDescOutPicWidth(aclvdecChannelDesc *channelDesc, uint32_t outPicWidth)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescOutPicWidth(channelDesc, outPicWidth);
}

aclError aclvdecSetChannelDescOutPicHeight(aclvdecChannelDesc *channelDesc, uint32_t outPicHeight)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescOutPicHeight(channelDesc, outPicHeight);
}

aclError aclvdecSetChannelDescRefFrameNum(aclvdecChannelDesc *channelDesc, uint32_t refFrameNum)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescRefFrameNum(channelDesc, refFrameNum);
}

aclError aclvdecSetChannelDescOutPicFormat(aclvdecChannelDesc *channelDesc, acldvppPixelFormat outPicFormat)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescOutPicFormat(channelDesc, outPicFormat);
}

aclError aclvdecSetChannelDescChannelId(aclvdecChannelDesc *channelDesc, uint32_t channelId)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescChannelId(channelDesc, channelId);
}

aclError aclvdecSetChannelDescBitDepth(aclvdecChannelDesc *channelDesc, uint32_t bitDepth)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    ACL_REQUIRES_TRUE((videoProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "videoProcessor can not be null");
    return videoProcessor->aclvdecSetChannelDescBitDepth(channelDesc, bitDepth);
}

uint32_t aclvdecGetChannelDescBitDepth(const aclvdecChannelDesc *channelDesc)
{
    const auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    if (videoProcessor == nullptr) {
        ACL_LOG_ERROR("[Check][VideoProcessor]video processor is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"videoProcessor"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return 0U;
    }
    return videoProcessor->aclvdecGetChannelDescBitDepth(channelDesc);
}

acldvppHist* acldvppCreateHist()
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_NOT_NULL_RET_NULL(imageProcessor);
    return imageProcessor->acldvppCreateHist();
}

aclError acldvppDestroyHist(acldvppHist *hist)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppDestroyHist(hist);
}

uint32_t acldvppGetHistDims(acldvppHist *hist)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    if (imageProcessor == nullptr) {
        ACL_LOG_ERROR("[Check][Imageprocessor]image processor is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"imageProcessor"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return static_cast<uint32_t>(ACL_ERROR_INTERNAL_ERROR);
    }
    return imageProcessor->acldvppGetHistDims(hist);
}

aclError acldvppGetHistData(acldvppHist *hist, uint32_t dim, uint32_t **data, uint16_t *len)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppGetHistData(hist, dim, data, len);
}

uint32_t acldvppGetHistRetCode(acldvppHist* hist)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    if (imageProcessor == nullptr) {
        ACL_LOG_ERROR("[Check][Imageprocessor]image processor is null.");
        const char_t *argList[] = {"param"};
        const char_t *argVal[] = {"imageProcessor"};
        acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_NULL_POINTER_MSG,
            argList, argVal, 1U);
        return static_cast<uint32_t>(ACL_ERROR_INTERNAL_ERROR);
    }
    return imageProcessor->acldvppGetHistRetCode(hist);
}

aclError acldvppClearHist(acldvppHist *hist)
{
    const auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    ACL_REQUIRES_TRUE((imageProcessor != nullptr), ACL_ERROR_INTERNAL_ERROR, "imageProcessor can not be null");
    return imageProcessor->acldvppClearHist(hist);
}
